<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div style="text-align: center;">
			<select name="" id="se1">
				<option value="">选择大小</option>
				<option value="大">选大</option>
				<option value="小">选小</option>
			</select>
			<br />
			<br />
			<br />
			<br />
			<br />

			<br />
			<img src="img/摇色子/1.jpg" alt="" width="110px" height="110px" id="imgid">
			<br />
			<button type="button" onclick="cliall()">开始</button>
		</div>
	
	</body>
		<script>
			var seobj=document.getElementById('se1');
			function cliall(){
			   // event.target.value='开始循环';
			   var ii=0;
				if (seobj.value=='') {
					alert('请下注!!');
					return false;
				}
				var temp=setInterval(function(){
					var imgobj=document.getElementById('imgid');
					var k=inter();
					console.log('输出点数'+k);
					var str='img/摇色子/'+k+'.jpg'
					imgobj.src=str;
					ii++;
					if(ii>20){
						clearInterval(temp);
						aa(k);
					}
				},150);
			};
			function inter(){
				while(true){
					var i=Math.ceil(Math.random()*6)
					if (i!==0) {
						return i;
					}
				}
			}
			function aa(k){
				if (seobj.value=='大') {
					if (k>3) {
						alert('你赢了！');
					}else{
						alert('你输了');
					}
				}else if (seobj.value=='小') {
					if (k<4) {
						alert('你赢了！');
					}else{
						alert('你输了');
					}
				}
			}
		</script>
	</html>